package logic

import (
	"context"
	"gorm.io/gorm"
	"house/models/mysql"

	"house/houserpc/houserpc"
	"house/houserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type BookingPrefectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBookingPrefectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BookingPrefectLogic {
	return &BookingPrefectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *BookingPrefectLogic) BookingPrefect(in *houserpc.BookingPrefectRequest) (*houserpc.BookingPrefectResponse, error) {
	// todo: add your logic here and delete this line
	booking := mysql.Booking{
		Model:   gorm.Model{ID: uint(in.BookingId)},
		UserId:  int(in.UserId),
		HouseId: int(in.HouseId),
		Name:    in.Name,
		Mobile:  in.Mobile,
		Address: in.Address,
		Types:   in.Types,
		Area:    in.Area,
		Status:  in.Status,
	}
	mysql.DB.Debug().Updates(&booking)
	return &houserpc.BookingPrefectResponse{
		Bookingid: int64(booking.ID),
	}, nil
}
